import os
from collections import defaultdict


if __name__ == '__main__':
    ctl = defaultdict(list) # compression time list
    dtl = defaultdict(list) # decompressino time list
    use_scalar = 0
    for use_scalar in [0,1]:
        for x in range(5):
            ctl[use_scalar].append(0)
            dtl[use_scalar].append(0)
        for x in range(5, 26):
            os.system(f"./onebit.o {x} {use_scalar}")
            with open("ret.txt", 'r') as f:
                ctl[use_scalar].append(float(f.readline().strip()))
                dtl[use_scalar].append(float(f.readline().strip()))
    with open("benchmark_onebit.csv", 'w') as f:
        f.write(f"""
Benchmark Onebit:
parmas:
    #""")
        f.write(','.join(['CT(us)', '0', '1'])+'\n')
        for x in range(5, 26):
            f.write(f"{x}, {ctl[0][x]}, {ctl[1][x]}\n")
            f.write('\n')

        f.write('\n')
        f.write(','.join(['DT(us)', '0', '1'])+'\n')
        for x in range(5,26):
            f.write(f"{x}, {ctl[0][x]}, {ctl[1][x]}\n")
            f.write('\n')
